\pard\tx7140\b0\fs28\li2100 INHERITS FROM ResultObject\
\fs16 \
\fs28 DECLARED IN TextConverter.h\
\fs16 \
\
\
\fs28 CLASS DESCRIPTION\
\fs16 \
\pard\tx3120\tx3620\tx4120\fs28\li2620 The TextConverter class serves as a base class for new classes. It provides little functionality on its own. Classes decended from TextConverter will convert text from one character set to another. For instance, a subclass might convert text from a Macintosh file to equivalent text for a NeXT application. The TextConverter class, itself, merely takes Characters, and returns them to the caller unaltered.\
\fs16 \
\fs28 There are two primarly methods provided by TextConverter, and they should be overridden by all subclasses.
\i ConvertCharacter:
\i0 takes a single character, and returns an equivalent character in the destination character set (e.g. if it is passed a Mac 0xA5 (bullet) character, it might return the character 0xB7 (a bullet in the NeXT character set)). If the character can not be mapped to a single character, then the subclass is free to choose whether to leave the value unchanged, or make an approximation. The second method,
\i ConvertString:WithLength:
\i0 also converts from one character set to another. Unlike
\i ConvertCharacter:
\i0 , it allows for converting a single character to multiple (e.g. a greater than or equal sign in one character set might be mapped to the pair of characters `>=').\
\fs16 \
\fs28 This class does not have specialized
\i init
\i0 or
\i free
\i0 methods. The inherited ones work adequately. Note that this class is essentially just a pair of functions bundled up as a fancy class! =)\
\
\fs16 \
\pard\tx7140\li2100 \
\
\fs28 INSTANCE VARIABLES\
\fs16 \
\pard\tx7140\tx10180\tx10680\i\fs28\fi-4540\li7140 Declared in TextConverter
\pard\tx3120\tx3620\tx4120\b0\fs28\li2620 This returns a single character in the destination character set that most closely matches the character value that it is provided. In this TextConverter class, this method merely returns the value it was passed.\
\pard\tx3120\tx3620\tx4120\b0\fs28\li2620 This method takes a pointer to a string of
\i length
\i0 characters (
\i length
\i0 should be a character count, not a byte count, should the two ever be different). Like
\b ConvertCharacter:
\b0 , this will convert characters in the source data, which are assumed to be in one character set, into characters in its destination character set. The TextConverter class merely maps each incomming character to an identical outgoing character. There are two things to note in particular about this method. This method allows for mapping multiple source characters to single destination characters, or single source to multiple destination characters. Because of this, it can not directly modify the source string. Consequently, it always allocates a new block of memory, and converts into it. A pointer to this new block is returned, along with the length of the converted data. This data can later be deallocated with FreePointer(). \
\fs16 \
\pard\tx7140\b\li2100 \
\b0 \
\fs28 BUGS AND PROBLEMS\
\fs16 \
\pard\tx3120\tx3620\tx4120\fs28\li2620 none yet\
\fs16 \
\pard\tx7140\li2100 \
\
\fs28 ENHANCEMENT IDEAS\
\fs16 \
\pard\tx3120\tx3620\tx4120\fs28\li2620 none\
\fs16 \
\pard\tx7140\li2100 \
\
\fs28 CONSTANT, DEFINED TYPES AND ERROR CODES\
\fs16 \
\pard\tx6480\tx7180\fs24\fi-3860\li6480 \
#define errCANTMAPTOONE 1001 /* set by ConvertChar: if mapping would be > 1 dest char */\
#define errCANTMAPFROMONE 1002 /* set by ConvertChar: if mapping needs > 1 source char */\